#pragma once

#include "BaseWriter.h"

class CFileWriter : public CBaseWriter
{
public:
  CFileWriter() : m_hFile(NULL), m_bUtf8(false)
  {}
  CFileWriter(const TCHAR* szFile, bool bUtf8 = true) : m_hFile(NULL), m_bUtf8(false)
  { Open(szFile, bUtf8); }
  ~CFileWriter()
  { Close(); }

  static const TCHAR eol[];

  bool Open(const TCHAR* szFile, bool bUtf8 = true);
  void Close();

  bool Write(const TCHAR* s);

  bool WriteLine(const TCHAR* s);

protected:
  void WriteUtf8();

protected:
  FILE* m_hFile;
  bool  m_bUtf8;

  static const char ceol[];
};
